#include "dttrack.h"

#include "dtartist.h"
#include "dtalbum.h"

DtTrack::DtTrack()
{
    name.clear();
    time.currentTime();
    lyrics.clear();
    number = -1;
    score = -1;
    recovery = NULL;
    location = "";
}

DtTrack::DtTrack(const QString &location, const QString & name,
                 const int number, const int id, DtAlbum * album,
                 DtArtist * artist, DtGenre * genre,
                 const QTime & time, const QString & lyrics, const int score,
                 DtTrack * recovery, const bool heart)
{
    this->id = id;
    this->name = name;
    this->time = time;
    this->lyrics = lyrics;
    this->number = number;
    this->score = score;
    this->recovery = recovery;
    this->heart.setHeart(heart);
    this->location = location;
    this->album.append(album);
    this->artist.append(artist);
    this->genre.append(genre);
}

DtTrack::DtTrack(const DtTrack & track)
{
    this->id = track.id;
    this->name = track.name;
    this->time = track.time;
    this->lyrics = track.lyrics;
    this->number = track.number;
    this->score = track.score;
    this->recovery = track.recovery;
    this->heart.setHeart(track.heart.isHeart());
    this->location = track.location;
    this->album = track.album;
    this->artist = track.artist;
    this->genre = track.genre;
}

DtTrack::~DtTrack()
{
}

QDebug operator<<(QDebug dbg, const DtTrack &track)
{
    dbg.space() << "Track" << track.getId() << track.getName()
                << track.getTime() << track.getNumber() << track.getLocation();
    return dbg.space();
}

void DtTrack::clicked(const int section)
{
    switch (section) {
    case DtTrack::Play: /* Play */
        playSvg.setPlay(!playSvg.isPlay());
        break;
    case DtTrack::Add: /* Ajouter */
        break;
    case DtTrack::Name: /* Titre du track*/
        break;
    case DtTrack::Heart: /* Heart */
        heart.setHeart(!heart.isHeart());
        //DbTrack::setHeart(*this);
        break;
    default:
        break;
    }
}

QTime DtTrack::getTime() const
{
    return time;
}

void DtTrack::setTime(const QTime &time)
{
    this->time = time;
}

QString DtTrack::getLyrics() const
{
    return lyrics;
}

void DtTrack::setLyrics(const QString &lyrics)
{
    this->lyrics = lyrics;
}

int DtTrack::getNumber() const
{
    return number;
}

void DtTrack::setNumber(const int number)
{
    this->number = number;
}

int DtTrack::getScore() const
{
    return score;
}

void DtTrack::setScore(const int score)
{
    this->score = score;
}

DtTrack * DtTrack::getRecovery() const
{
    return recovery;
}

void DtTrack::setRecovery(DtTrack *recovery)
{
    this->recovery = recovery;
}

QString DtTrack::getLocation() const
{
    return location;
}

void DtTrack::setLocation(const QString &location)
{
    this->location = location;
}

void DtTrack::setAlbum(DtAlbum *album)
{
    this->album.append(album);
}

void DtTrack::setArtist(DtArtist *artist)
{
    this->artist.append(artist);
}

void DtTrack::setGenre(DtGenre *genre)
{
    this->genre.append(genre);
}

QList<DtAlbum *> &DtTrack::getAlbums()
{
    return album;
}

QList<DtArtist *> &DtTrack::getArtists()
{
    return artist;
}

QList<DtGenre *> &DtTrack::getGenres()
{
    return genre;
}
